// 让小球向右下运动，遇到边缘后反弹
var ball = document.querySelector('.ball');
var ballSpeedX = 5,
  ballSpeedY = 5;

 var rect= ball.getBoundingClientRect();
 var ballWidth = rect.right-rect.left;
 var ballHeight = rect.bottom-rect.top;
 var startLeft= rect.left;
 var startTop= rect.top;

var maxLeft=document.documentElement.clientWidth-ballWidth;
var maxTop=document.documentElement.clientHeight-ballHeight;

function moveBall() {
   ball.style.left=startLeft+ballSpeedX+"px";
}

function start() {
  setInterval(() => {
    moveBall();
  }, 50);
}
